﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;
using System.Data.SqlClient;

namespace MainFrame
{
    /// <summary>
    /// 数据库操作父类
    /// </summary>
    [Serializable]
    public abstract class DB_base
    {
        /// <summary>
        /// 打开数据库
        /// </summary>
        /// <returns>成功打开返回true，否则返回false</returns>
        public virtual bool OpenDB()
        {
            return true;
        }
        /// <summary>
        /// 删除数据库
        /// </summary>
        /// <returns>成功删除返回true，否则返回false</returns>
        public virtual bool DeleteDB()
        {
            return true;
        }
        /// <summary>
        /// 创建数据表
        /// </summary>
        /// <param name="TableName">表名称</param>
        /// <param name="colNames">表中列名称</param>
        /// <param name="colTypes">表中列对应的数据类型</param>
        /// <returns>成功创建返回true，否则返回false</returns>
        public virtual bool CreateTable(string TableName,string[] colNames,string[] colTypes)
        {
            return true;
        }
        /// <summary>
        /// 删除表
        /// </summary>
        /// <param name="TableName">表名称</param>
        /// <returns>成功删除返回true,否则返回false</returns>
        public virtual bool DeleteTable(string TableName)
        {
            return true;
        }

        public virtual bool QueryFullTable(string TableName,ref SQLiteDataReader sqliteReader)
        {
            return true;
        }
        public virtual bool QueryFullTable(string TableName, ref SqlDataReader sqlReader)
        {
            return true;
        }
        public virtual bool ExecuteQuery(string queryString, ref SQLiteDataReader sqliteReader)
        {
            return true;
        }

        public virtual bool CloseDB()
        {
            return true;
        }

        public virtual bool InsertInto(string tableName,string[] context,ref SQLiteDataReader sqliteReader)
        {
            return true;
        }
        public virtual bool ReadTable(string tableName, string[] items, string[] colNames, string[] operations,
            string[] colOperas, string[] colType,ref SQLiteDataReader sqliteReader)
        {
            return true;
        }
        public virtual bool ReadTable(string tableName,string colNames, string operations, 
            string colValue,ref SQLiteDataReader sqliteReader)
        {
            return true;
        }
        public virtual bool DeleteInfo(string tableName,string[] colNames,string[] operations,string[] colOperas, string [] colValues)
        {
            return true;
        }
        public virtual bool DeleteInfo(string tableName, string colName, string operations, string colValue)
        {
            return true;
        }
        public virtual bool UpdateInfo(string tableName,string[] colNames,string[] colValues,string key,string keyValue,string operation)
        {
            return true;
        }
    }
}
